﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;

namespace SimpleMap.Setters
{
    public class PropertySetterValueFactory<T>:IPropertyValueSetterFactory<T>
    {

        private bool _useCodeGeneration;

        public PropertySetterValueFactory(bool useCodeGeneration) 
        {
            _useCodeGeneration = useCodeGeneration;
        }
        
        
        public IValueSetter<T> CreateSetter(PropertyInfo property)
        {
            if (_useCodeGeneration) 
            {
                return new DynamicILPropertyValueSetter<T>(property);
            }
            else
            {
            return new ReflectionPropertyValueSetter<T>(property);
            }
        }
    }
}
